package game.Actors;
import java.util.Random;
import game.Config.Config;
import org.newdawn.slick.Animation;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Vector2f;
/**
 * This class represents a fireeffect in the game.
 * This class extends the effect class and will thus affect an
 * enemy each update. The affected enemy will burn each update, taking damage.
 * @author Sebastian Isheden and Victor Beer.
 *
 */
public class FireEffect extends Effect{
	private Animation animation;
	private float damage;
	private Vector2f offset;
	/**
	 * Creates a Fireffect based on given parameters.
	 * @param animation The animation of the fire effect.
	 * @param position The position of the enemy this effect will affect.
	 * @param maximumTime The maximum time this effect will last.
	 * @param target The target of this effect.
	 * @param damage The total damage the fire will hurt it's target.
	 */
	public FireEffect(SpriteSheet animation, Vector2f position, float maximumTime,Enemy target,float damage) {
		super(null, position, maximumTime, target);
		Random random = new Random();
		offset = new Vector2f(0,0);
		offset.x = this.target.image.getWidth()/2 - (random.nextFloat())*this.target.image.getWidth();
		offset.y = this.target.image.getHeight()/2 - (random.nextFloat())*this.target.image.getHeight();
		this.animation = new Animation(animation,Config.STANDARD_DURATION);
		this.damage = damage;
	}
	@Override
	protected void draw(){
		animation.draw(position.x- animation.getWidth()/2 + this.offset.x, position.y - animation.getHeight()/2 + this.offset.y);
	}
	@Override
	protected void affectTarget(int delta) {
		target.hit(damage*delta/Config.MILLISECONDS);
	}
	@Override
	protected void resetEnemy() {
		
	}
}
